<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class unit_model extends CI_Model
{
	
	public function __construct()
	{
		parent::__construct();
		$data=array();

	} 	
		
	
	
	public function insert($name, $description ,$additional_data){
		
		$data = array(
			    'name'   => $name,
				'description' =>$description
		 );
		$this->db->insert('unit',$data);
			
}
		
	public function get_unit(){
		
		$query = $this->db->get('unit');

		return $query;
	}	

public function edit_unit($id){
		$query = $this->db->get_where('unit', array('id' => $id));
		return $query;
	}

public function update($edit_id, $data){
		$this->db->update('unit',$data,array('id'=>$edit_id));
	}

public function delete($id){
		$this->db->delete('unit',array('id'=>$id));		
	}
	
	
public function get(){
	   $this->datatables
			->select("id,name,description")
			->from("unit")		
			->add_column("Actions", 
			"<center>			<a href='edit_unit/$1'>
								<i class='icon-edit'></i>
								</a>
							    <a href='delete_unit/$1' onClick=\"return confirm('". 'Do U Want To Delete Category! ' ."')\">
								<i class='icon-trash'></i>
								</a></center>", "id")
			->unset_column('id');
		
		
	   return  $this->datatables->generate();
	
}	


}
